home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 03 - 1987 / 03.01 Jan 87 / basic source / Dialog Example.BAS next >
Encoding:
BASIC Source File  |  1986-11-22  |  3.5 KB  |  138 lines  |  [TEXT/ZBAS]

  1. REM ZBasic Dialog Example
  2. REM ©MacTutor 1987
  3. REM By Dave Kelly
  4. WINDOW OFF:REM Always use this as first line of program to prevent default window from being created
  5. COORDINATE WINDOW:REM Set window to Macintosh coordinate system
  6. False=0:True=NOT False
  7. IF PEEK(&28E) AND 128 THEN Wtype=1 ELSE Wtype=9
  8. Wtype=1:REM  Due to Bugs in ZBasic 3.02 Zoom window will not be used.
  9. MENU 1,0,1,"File"
  10. MENU 1,1,1,"Quit"
  11. DIALOG OFF
  12. WINDOW 1,"Window 1",(10,50)-(250,200),Wtype
  13. TEXT 4,9,0,0
  14. BUTTON 1,1,"Button 1",(20,20)-(100,50)
  15. BUTTON 2,1,"Button 2",(20,60)-(100,90)
  16. WINDOW 2,"Window 2",(275,50)-(500,200),Wtype
  17. TEXT 4,9,0,0
  18. EDIT FIELD 1,"",(10,10)-(100,35),1,1
  19. EDIT FIELD 2,"",(10,40)-(100,65),1,1
  20. WINDOW 3,"Dialog Event (Window #3)",(10,250)-(500,340),28
  21. TEXT 4,9,0,0
  22. ON DIALOG   GOSUB "DialogEvent"
  23. ON BREAK    GOSUB "BreakEvent"
  24. ON MENU GOSUB "MenuEvent"
  25. DIALOG ON:BREAK ON:MENU ON
  26. "Mainloop":DO:D=DIALOG(0):IF D>0 THEN GOSUB "DEvent"
  27. UNTIL D=0
  28. GOTO "Mainloop"
  29. "MenuEvent"
  30. DIALOG STOP:
  31. Menunumber=MENU(0):Itemnumber=MENU(1)
  32. IF Menunumber=1 AND Itemnumber=1 THEN END
  33. DIALOG ON
  34. RETURN
  35. "BreakEvent"
  36. STOP
  37. "DialogEvent"
  38. D = DIALOG(0):REM check to see what event occured
  39. "DEvent"
  40. DIALOG STOP
  41. Currentwindow = WINDOW(0)
  42. Windowselection = WINDOW(1)
  43. WINDOW OUTPUT 3
  44. IF D = 1 GOSUB "Buttonevent"
  45. IF D = 2 GOSUB "EditEvent"
  46. IF D = 3 GOSUB "InactiveWindow"
  47. IF D = 4 GOSUB "Closebox"
  48. IF D = 5 GOSUB "Refresh"
  49. IF D = 6 GOSUB "Returnkey"
  50. IF D = 7 GOSUB "Tabkey"
  51. IF D = 8 GOSUB "Zoomin"
  52. IF D = 9 GOSUB "Zoomout"
  53. IF D =10 GOSUB "Shifttab"
  54. IF D =11 GOSUB "Clearkey"
  55. IF D =12 GOSUB "LeftArrow"
  56. IF D =13 GOSUB "RightArrow"
  57. IF D =14 GOSUB "UpArrow"
  58. IF D =15 GOSUB "DownArrow"
  59. IF D =16 GOSUB "Keypress"
  60. PRINT @(50,3) "DIALOG(0) :        ";D
  61. PRINT @(50,4) "Active Window #";Currentwindow
  62. PRINT @(50,5) "Output Window #";Windowselection
  63. WINDOW OUTPUT Outwindow:WINDOW Windowselection
  64. DIALOG ON
  65. RETURN
  66. "Buttonevent"
  67. Buttonclicked=DIALOG(1)
  68. Bstatus=BUTTON(Buttonclicked):BUTTON Buttonclicked,3-Bstatus
  69. PRINT@(1,1)   "Button clicked :   ";Buttonclicked
  70. RETURN
  71. "EditEvent":
  72. EditField=DIALOG(2)
  73. PRINT@(1,2)   "Edit Field :       ";EditField
  74. RETURN
  75. "InactiveWindow"
  76. Windowselection=DIALOG(3)
  77. PRINT@(1,3)   "Inactive Window :  ";Windowselection
  78. RETURN
  79. "Closebox":
  80. ClosedWindow=DIALOG(4)
  81. IF ClosedWindow=3 THEN END
  82. PRINT@(1,4)   "Closed Window :    ";ClosedWindow
  83. RETURN
  84. "Refresh":
  85. ErasedWindow=DIALOG(5)
  86. PRINT @(1,5)  "Erased Window :    ";ErasedWindow
  87. RETURN
  88. "Returnkey":
  89. Returnpress=DIALOG(6)
  90. PRINT @(25,1) "Return press :     ";Returnpress
  91. RETURN
  92. "Tabkey":
  93. Tabpress=DIALOG(7)
  94. PRINT @(25,2) "Tab press :        ";Tabpress
  95. RETURN
  96. "Zoomin": REM NEW ROMS ONLY
  97. Zin=DIALOG(8)
  98. WINDOW Zin
  99. PRINT@(1,1) "Thank you for zooming in window";Zin
  100. PRINT @(25,3) "Zoom in window :   ";Zin
  101. RETURN
  102. "Zoomout":
  103. Zout=DIALOG(9)
  104. WINDOW Zout
  105. PRINT@(1,1)"Thank you for zooming out window";Zout
  106. PRINT @(25,4) "Zoom out window :  ";Zout
  107. RETURN
  108. "Shifttab":
  109. CurrentEdit=DIALOG(10)
  110. PRINT @(25,5) "Current Edit Field:";CurrentEdit
  111. RETURN
  112. "Clearkey":
  113. CurrentEdit=DIALOG(11)
  114. PRINT @(25,5) "Current Edit Field:";CurrentEdit
  115. RETURN
  116. "LeftArrow":
  117. CurrentEdit=DIALOG(12)
  118. PRINT @(25,5) "Current Edit Field:";CurrentEdit
  119. RETURN
  120. "RightArrow":
  121. CurrentEdit=DIALOG(13)
  122. PRINT @(25,5) "Current Edit Field:";CurrentEdit
  123. RETURN
  124. "UpArrow":
  125. CurrentEdit=DIALOG(14)
  126. PRINT @(25,5) "Current Edit Field:";CurrentEdit
  127. RETURN
  128. "DownArrow":
  129. CurrentEdit=DIALOG(15)
  130. PRINT @(25,5) "Current Edit Field:";CurrentEdit
  131. RETURN
  132. "Keypress":
  133. ASCIIkey=DIALOG(16)
  134. PRINT @(50,1) "ASCII key pressed :";ASCIIkey;"  "
  135. PRINT @(75,1) " ":PRINT @(75,1) CHR$(ASCIIkey)
  136. RETURN
  137. END
  138.